---
title: "Online Appendix for 'Party ideology and care policy: the decline of institutional care since 1950'"
author: "Katren Rogers"
date: "Updated 18 December 2024"
bibliography: bibliography.bib
output:
  html_document:
    toc: yes
---

```{r load_packages, include=F}
library(readxl)
library(tidyverse)
library(dplyr)
library(ggplot2)
library(scales)
library(haven)
library(ggpubr)
library(ggsci)
library(knitr)
library(kableExtra)
```

\
This is the online appendix for:\
Katren Rogers. forthcoming. "Party ideology and care policy: the decline of institutional care since 1950". *Journal of European Social Policy*.\
\

# Tables from the paper 

### Table 2: Peak institutional populations (listed by date of peak asylum population)
```{r, echo=FALSE}
country <- c("England", "United States", "Ireland", "Canada", "Sweden", "Italy", "Australia", "France", "New Zealand", "Denmark", "Germany", "Netherlands")
asylums <- c(1954, 1955, 1959, 1962, 1963, 1963, 1963, 1970, 1972, 1972, 1975, 1984)
orphanages <- c(1948, 1935, 1970, 1965, 1940, 1975, 1961, 1975, 1975, 1957, 1977, 1969)

df <- data.frame(Country = country, Asylums = asylums, Orphanages = orphanages)

knitr::kable(df, 
             align = 'lcc') %>%
    kable_styling(bootstrap_options = c("striped"), full_width = FALSE) %>%
  column_spec(1:3,width = "4cm") %>%
  footnote(general = c(
    "@brunton2003 p. 83; @dekker2012 p. 41; @delvalle2009; @donnelly1992 p. 87; @durie1999; @finnane2009; @gilligan2009; @goodwin1997 pp. 86--87; @hardera2013; @jonesK1993 p. 161; @licursi2013; @madianos1994; @masson2000 p. 567; @rochefort1993 p.225; @sallnas1995 p. 336; @sedgwick1982 p. 221; @senate2004 appendix 5; @socialstyrelsen1982 p. 10; @soland2015; @walsh2004 p. 77; @weeke1986."
  ),general_title = "Sources: ",footnote_as_chunk = T)


```

### Table 4: Full Model, Multinomial logistic regression on type of policy change

```{r, echo=FALSE}

df <- read.csv("table_appendix.csv", header=F)
df <- df[-c(1:3), ]
colnames(df) <- c("", "State", "Market", "Family", "Voluntary")
df[, 1] <- c("Christian democrat", "", 
                "Conservative", "", 
                "Liberal","",
                "Policy area", "",
                "WFR=Conservative", "",
                "WFR=Soc. Dem.", "",
                "GDP p.c.", "",
                "Coalition", "",
                "Federal", "", 
                "Fem. Lab.", "",
                "Instititions=Vol. secular", "",
                "Instititions=Religious","", 
                "Previous Change", "",
                "1960s", "",
                "1970s", "",
                "1980s", "",
                "1990s", "",
                "2000s","",
                "2010s", "",
                "Constant", "",
                "N",
                "Log-likelihood",
                "AIC",
                "BIC")

df[c(41:44),4]<- df[c(41:44),2]
df <- df[, -c(2)]

kable(df, row.names=F, align = 'lcccc') %>%
  kable_styling(bootstrap_options = c("striped"), full_width = FALSE) %>%
  column_spec(1, bold = TRUE)


```


# Figures from the paper

### Figure 2: Policy changes in each category, by policy area and government partisanship, and over time

```{r figure_2, include=T, echo=F,fig.width=8.6,fig.height=10.6}

df <- read_dta("Care_policy_dataset_Rogers.dta") # Main dataset

plotdata <- tibble()
for (i in seq_along(c("state", "market", "famil", "civilsoc"))) {
  variable <- c("state", "market", "famil", "civilsoc")[i]
  plotdata <- plotdata %>%
    bind_rows(df %>%
        group_by(servicetype, lead) %>%
        summarise(value = sum(!!sym(variable)), .groups = "drop") %>%
        mutate(Outcome = i))
  }

plotdata$Outcome <- factor(plotdata$Outcome,levels = c(1,2,3,4), 
                           labels = c("State", "Market", "Family", "Voluntary"))
plotdata$lead <- factor(plotdata$lead,levels = c(1,2,3,4), 
                        labels = c("Social democrat", "Christian democrat", "Conservative", "Liberal"))

MH_dist <-ggplot(subset(plotdata, servicetype=="asylums"),
                 aes(x = lead, y = value, group=Outcome, fill = Outcome)) +
  geom_bar(stat='identity', position=position_dodge2(preserve = "single"), alpha=0.6) +
  scale_fill_lancet(name = "Outcome",labels = c("State", "Market", "Family", "Voluntary")) +
  scale_alpha(guide = 'none') + theme_classic() +
  scale_x_discrete(name="", labels= c("Social democrat", "Christian democrat", "Conservative",
                                      "Liberal"), drop=F, expand = c(0,0)) +
  scale_y_continuous(name="", limits=c(0, 15), expand = c(0,0)) +
  theme(axis.text.x= element_text(size=10), 
        axis.text.y= element_blank(), 
        axis.line=element_blank(), 
        axis.ticks=element_blank()) + 
  ggtitle("Mental health policy changes") + 
  geom_text(aes(label= value, group=Outcome), position=position_dodge(width=0.9), vjust = -0.5)

CW_dist <-ggplot(subset(plotdata, servicetype=="orphanages"), 
                 aes(x = lead, y = value, group=Outcome, fill = Outcome)) + 
  geom_bar(stat='identity', position=position_dodge2(preserve = "single"), alpha=0.6) +
  scale_fill_lancet(name = "Outcome",labels = c("State", "Market", "Family", "Voluntary")) +
  scale_alpha(guide = 'none') + theme_classic() + 
  scale_x_discrete(name="", labels= c("Social democrat", "Christian democrat", "Conservative",
                                      "Liberal"), drop=F, expand = c(0,0)) +
  scale_y_continuous(name="", limits=c(0, 14), expand = c(0,0)) + 
  theme(axis.text.x= element_text(size=10), 
        axis.text.y= element_blank(), 
        axis.line=element_blank(), 
        axis.ticks=element_blank()) + 
  ggtitle("Child welfare policy changes") + 
  geom_text(aes(label= value, group=Outcome), position=position_dodge(width=0.9), vjust = -0.5)


df <- read_dta("Care_policy_dataset_Rogers.dta")
df$poltype <- factor(df$poltype,levels = c(1,2,3,4), labels = c("State", "Market", "Family", "Voluntary"))

desc_time <- ggplot(df, aes(x=year, group=poltype, fill=poltype)) + geom_density(alpha=0.5) +
  scale_fill_lancet(name = "Outcome",labels = c("State", "Market", "Family", "Voluntary")) +
  scale_alpha(guide = 'none') + theme_classic() + 
  theme(axis.line.y = element_blank(), 
        axis.ticks.y=element_blank(), 
        axis.text.y=element_blank(), 
        axis.title.y = element_blank(), 
        axis.text.x= element_text(size=11), 
        plot.margin = unit(c(0, 0, 0, 0.8), "cm")) + 
  scale_x_continuous(name="   ", breaks=seq(1950, 2015, by = 10), 
                     limits=c(1950, 2015), expand = c(0, 0)) + 
  scale_y_continuous(expand = c(0,0)) + ggtitle("Distribution over time") 

ggarrange(MH_dist, CW_dist, desc_time, common.legend = TRUE, legend = "right", ncol = 1, nrow=3)

```

### Figure 3: Average marginal effect of a change in government partisanship

```{r figure_3, include=T, echo=F, message=F, warning=F, width = 5, height = 4.3}

df <- read_excel("mchange.xlsx") # Marginal change dataset generated in stata

colnames(df) <- c("groupID","label", "state", "market", "family", "voluntary")
df$datapoint <- c("P", "LL", "UL", "P", "LL", "UL", "P", "LL", "UL", "P", "LL", "UL", "P", "LL", "UL", "P", "LL", "UL")

plotdata<-select(df, groupID, datapoint, state)
plotdata$groupID <- c(1,1,1,6,6,6,11,11,11,16,16,16,21,21,21,26, 26, 26)
plotdata$outcome<-("1")
colnames(plotdata) <- c("groupID","datapoint", "value", "Outcome")

plotdata2<-select(df, groupID, datapoint, market)
plotdata2$groupID <- c(2,2,2,7,7,7,12,12,12,17,17,17,22,22,22,27,27,27)
plotdata2$outcome<-("2")
colnames(plotdata2) <- c("groupID","datapoint", "value", "Outcome")

plotdata3<-select(df, groupID, datapoint, family)
plotdata3$groupID <- c(3,3,3,8,8,8,13,13,13,18,18,18,23,23,23,28,28,28)
plotdata3$outcome<-("3")
colnames(plotdata3) <- c("groupID","datapoint", "value", "Outcome")

plotdata4<-select(df, groupID, datapoint, voluntary)
plotdata4$groupID <- c(4,4,4,9,9,9,14,14,14,19,19,19,24,24,24,29,29,29)
plotdata4$outcome<-("4")
colnames(plotdata4) <- c("groupID","datapoint", "value", "Outcome")

plotdata<-rbind(plotdata,plotdata2,plotdata3,plotdata4)

plotdata$groupID <- as.numeric(plotdata$groupID)
plotdata$groupID <- (plotdata$groupID)*-1
plotdata$Outcome <- as.numeric(plotdata$Outcome)
plotdata$Outcome <- factor(plotdata$Outcome,levels = c(1,2,3,4), labels = c("State", "Market", "Family", "Voluntary"))

ggplot(plotdata) + geom_line(aes(value, groupID, group=groupID)) + 
  geom_point(data=(subset(plotdata, datapoint=="P")), aes(value, groupID, shape=Outcome)) + 
  coord_fixed(ratio=0.07) + geom_hline(yintercept=-5,color = "white", size=2) + 
  geom_hline(yintercept=-10,color = "white", size=2) + 
  geom_hline(yintercept=-15,color = "white", size=2) + 
  geom_hline(yintercept=-20,color = "white", size=2) + 
  geom_hline(yintercept=-25,color = "white", size=2) + 
  geom_vline(xintercept=0,linetype="dashed",color = "black", size=0.5) + 
  theme(panel.grid.major = element_blank(), panel.grid.minor= element_blank(), 
        axis.ticks.y=element_blank(), 
        axis.text.y = element_text(color="black", size=10), 
        legend.title = element_text(size=10), 
        axis.title.x= element_text(size=10)) + 
  scale_x_continuous(name="Effect on predicted probability \n\nAverage predictions: State=0.25 Market=0.16 Family=0.36 Voluntary=0.23", breaks=seq(-0.8, 0.8, by = 0.2), limits=c(-0.67, 0.67)) + 
  scale_y_continuous(name="", breaks=c(-2,-3,-7,-8,-12,-13,-17,-18,-22,-23,-27,-28), 
                     labels=c("Christian Democrat vs", "Social Democrat", 
                              "Conservative vs","Social Democrat",
                              "Liberal vs", "Social Democrat", 
                              "Conservative vs","Christian Democrat", 
                              "Liberal vs","Christian Democrat", 
                              "Liberal vs","Conservative"))

```

# Additional visualisations

### Policy changes by policy area and category, for each country over time

```{r poltype_country, include=T, echo=F,fig.width=8, fig.height=7}
df <- read_dta("Care_policy_dataset_Rogers.dta")

plotdata<-select(df, country, year, servicetype, poltype) %>%
  mutate(cID = ifelse(country=="USA", 14, 
               ifelse(country=="England", 13, 
               ifelse(country=="Australia", 12, 
               ifelse(country=="New Zealand", 11, 
               ifelse(country=="Canada", 10, 
               ifelse(country=="Ireland", 9, 
               ifelse(country=="Sweden", 7, 
               ifelse(country=="Denmark", 6, 
               ifelse(country=="Netherlands", 4, 
               ifelse(country=="Italy", 3, 
               ifelse(country=="Germany", 2, 1))))))))))))

plotdata$poltype <- factor(plotdata$poltype,levels = c(1,2,3,4), labels = c("State", "Market", "Family", "Voluntary"))

asylumplot<-ggplot(subset(plotdata, servicetype=="asylums")) +
  geom_point(aes(year, cID, group=cID, shape=poltype, colour=poltype), size=3, alpha=0.7) +
  theme(panel.grid.minor= element_blank(), 
        axis.ticks.y=element_blank(), 
        axis.text.y = element_text(color="black", size=10), 
        legend.title = element_text(size=10), 
        axis.title.x= element_text(size=10)) + 
  scale_y_continuous(name="", breaks=c(1,2,3,4,6,7,9,10,11, 12, 13, 14), 
                     labels=c("France", "Germany","Italy", "Netherlands", "Denmark", "Sweden", "Ireland", "Canada", "New Zealand", "Australia", "England", "USA")) +
  geom_hline(yintercept=5,color = "white", size=2) + 
  geom_hline(yintercept=8,color = "white", size=2) + 
  scale_x_continuous(name="", breaks=seq(1950, 2010, by = 10)) + 
  scale_shape_discrete(name = "Outcome",labels = c("State", "Market", "Family", "Voluntary")) +
scale_colour_lancet(name = "Outcome",labels = c("State", "Market", "Family", "Voluntary")) + ggtitle("Mental health")

orphanplot<-ggplot(subset(plotdata, servicetype=="orphanages")) + 
  geom_point(aes(year, cID, group=cID, shape=poltype,colour=poltype), size=3,alpha=0.7) + 
  theme(panel.grid.minor= element_blank(), 
        axis.ticks.y=element_blank(), 
        axis.text.y = element_text(color="black", size=10), 
        legend.title = element_text(size=10), 
        axis.title.x= element_text(size=10)) + 
  scale_y_continuous(name="", breaks=c(1,2,3,4,6,7,9,10,11, 12, 13, 14), 
                     labels=c("France", "Germany","Italy", "Netherlands", "Denmark", "Sweden", "Ireland", "Canada", "New Zealand", "Australia", "England", "USA")) +
  geom_hline(yintercept=5,color = "white", size=2) + 
  geom_hline(yintercept=8,color = "white", size=2) + 
  scale_x_continuous(name="", breaks=seq(1950, 2010, by = 10)) + 
  scale_shape_discrete(name = "Outcome",labels = c("State", "Market", "Family", "Voluntary")) +
scale_colour_lancet(name = "Outcome",labels = c("State", "Market", "Family", "Voluntary")) + ggtitle("Child welfare")

ggarrange(asylumplot, orphanplot, 
  common.legend = TRUE, legend = "right", ncol = 1)

```

### Policy changes by policy area and government partisanship, for each country over time

```{r lead_country, include=T, echo=F,fig.width=8, fig.height=7}

df <- read_dta("Care_policy_dataset_Rogers.dta")

plotdata<-select(df, country, year, servicetype, poltype,lead) %>%
  mutate(cID = ifelse(country=="USA", 14, 
               ifelse(country=="England", 13, 
               ifelse(country=="Australia", 12, 
               ifelse(country=="New Zealand", 11, 
               ifelse(country=="Canada", 10, 
               ifelse(country=="Ireland", 9, 
               ifelse(country=="Sweden", 7, 
               ifelse(country=="Denmark", 6, 
               ifelse(country=="Netherlands", 4, 
               ifelse(country=="Italy", 3, 
               ifelse(country=="Germany", 2, 1))))))))))))

plabs<-c("Social Democrat", "Christian Democrat", "Conservative", "Liberal")
ppal<-c("red3", "black", "royalblue3", "gold3")

plotdata$lead <- factor(plotdata$lead,levels = c(1,2,3,4), labels = plabs)

asylumplot<-ggplot(subset(plotdata, servicetype=="asylums")) +
  geom_point(aes(year, cID, group=cID, shape=lead, colour=lead, fill=lead), size=3) +
  theme(panel.grid.minor= element_blank(), 
        axis.ticks.y=element_blank(), 
        axis.text.y = element_text(color="black", size=10), 
        legend.title = element_text(size=10), 
        axis.title.x= element_text(size=10)) + 
  scale_y_continuous(name="", breaks=c(1,2,3,4,6,7,9,10,11, 12, 13, 14), 
                     labels=c("France", "Germany","Italy", "Netherlands", "Denmark", "Sweden", "Ireland", "Canada", "New Zealand", "Australia", "England", "USA")) +
  geom_hline(yintercept=5,color = "white", size=2) + 
  geom_hline(yintercept=8,color = "white", size=2) + 
  scale_x_continuous(name="", breaks=seq(1950, 2010, by = 10)) + 
  scale_shape_manual(name = "Leading party",labels = plabs,values = c(21, 22, 23, 24)) +
scale_colour_manual(name = "Leading party",labels = plabs, values = ppal) + 
      scale_fill_manual(name = "Leading party", labels = plabs, values = ppal) + 
                      ggtitle("Mental health")

orphanplot<-ggplot(subset(plotdata, servicetype=="orphanages")) + 
  geom_point(aes(year, cID, group=cID, shape=lead, colour=lead, fill=lead), size=3) +
  theme(panel.grid.minor= element_blank(), 
        axis.ticks.y=element_blank(), 
        axis.text.y = element_text(color="black", size=10), 
        legend.title = element_text(size=10), 
        axis.title.x= element_text(size=10)) + 
  scale_y_continuous(name="", breaks=c(1,2,3,4,6,7,9,10,11, 12, 13, 14), 
                     labels=c("France", "Germany","Italy", "Netherlands", "Denmark", "Sweden", "Ireland", "Canada", "New Zealand", "Australia", "England", "USA")) +
  geom_hline(yintercept=5,color = "white", size=2) + 
  geom_hline(yintercept=8,color = "white", size=2) + 
  scale_x_continuous(name="", breaks=seq(1950, 2010, by = 10)) + 
  scale_shape_manual(name = "Leading party",labels = plabs,values = c(21, 22, 23, 24)) +
scale_colour_manual(name = "Leading party",labels = plabs, values = ppal) + 
      scale_fill_manual(name = "Leading party", labels = plabs, values = ppal) + 
                      ggtitle("Child welfare")
  

ggarrange(asylumplot, orphanplot, 
  common.legend = TRUE, legend = "right", ncol = 1)

```

### Policy changes by welfare regime and government partisanship

```{r by_wfregime, include=T, echo=F, fig.width=8, fig.height=6}

df <- read_dta("Care_policy_dataset_Rogers.dta")

generate_plot <- function(data, wfregime_value, plot_title) {
  plotdata1 <- data %>%
    filter(wfregime == wfregime_value) %>%
    group_by(plotID) %>%
    mutate(Count = row_number()) %>%
    ungroup() %>%
    filter(plotID %in% c(1, 5, 10, 15))

  plabs <-c("Social Democrat", "Christian Democrat", "Conservative", "Liberal")

  plotdata1$lead <- factor(plotdata1$lead, levels = c(1, 2, 3, 4), labels = plabs)

  ggplot() + 
    geom_point(data = plotdata1, aes(plotID, Count, group = lead, color = lead, shape = lead, fill = lead), size = 3) + 
    theme_classic() + 
    theme(panel.grid.minor = element_blank(), 
          axis.text.x = element_text(color = "black", size = 8), 
          legend.title = element_text(size = 11), 
          legend.text = element_text(size = 11), 
          axis.title.y = element_text(size = 10)) + 
    scale_x_continuous(name = "", breaks = c(1, 5, 10, 15), limits = c(0, 16.5), labels = c("State", "Market", "Family", "Voluntary")) + 
    scale_y_continuous(name = "", limits = c(0, 26)) +   
    scale_colour_manual(name = "Leading party:", 
                        labels = plabs,
                        values = c("red3", "black", "royalblue3", "gold3"), drop = FALSE) +   
    scale_shape_manual(name = "Leading party:", 
                       labels = plabs,
                       values = c(21, 22, 23, 24), drop = FALSE) + 
    scale_fill_manual(name = "Leading party:", 
                      labels = plabs,
                      values = c("red3", "black", "royalblue3", "gold3"), drop = FALSE) + 
    theme(panel.grid = element_blank(), axis.ticks = element_blank(), axis.text.y = element_blank(), axis.line = element_blank(), 
          plot.title = element_text(hjust = 0.4), axis.text.x = element_text(size = 11)) + 
    ggtitle(plot_title)
}

plotdata <- df %>%
  select(wfregime, poltype, lead) %>%
  mutate(plotID = case_when(
    poltype == 1 ~ 1,
    poltype == 2 ~ 5,
    poltype == 3 ~ 10,
    TRUE ~ 15
  )) %>%
  select(wfregime, plotID, lead) %>%
  arrange(lead)

lib_plot <- generate_plot(plotdata, 1, "Liberal regimes")
cd_plot <- generate_plot(plotdata, 2, "Conservative regimes")
sd_plot <- generate_plot(plotdata, 3, "Social democratic regimes")

ggarrange(lib_plot, NULL, cd_plot, NULL, sd_plot, widths = c(1, 0.05, 1, 0.05, 1), common.legend = TRUE, legend = "bottom", ncol = 5, nrow=1, font.label = list(size=11))

```

# Table 2 References
